

<!doctype html>

<html lang="en" data-content_root="../../">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>skidl.skidl &#8212; SKiDL 1.2.2 documentation</title>
    <link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
    <link rel="stylesheet" type="text/css" href="../../_static/bizstyle.css?v=a66e137f" />
    
    <script src="../../_static/documentation_options.js?v=fd7cadf9"></script>
    <script src="../../_static/doctools.js?v=9a2dae69"></script>
    <script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
    <script src="../../_static/bizstyle.js"></script>
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0" />
    <!--[if lt IE 9]>
    <script src="_static/css3-mediaqueries.js"></script>
    <![endif]-->
  </head><body>
    <h1 id="site-title"><a href="../../../../"><img src="../../../../images/slim_banner.png" width="100%"></a></h1>
    
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">SKiDL 1.2.2 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../index.html" accesskey="U">Module code</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">skidl.skidl</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <h1>Source code for skidl.skidl</h1><div class="highlight"><pre>
<span></span><span class="c1"># -*- coding: utf-8 -*-</span>

<span class="c1"># The MIT License (MIT) - Copyright (c) Dave Vandenbout.</span>

<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="p">(</span>  <span class="c1"># isort:skip</span>
    <span class="n">absolute_import</span><span class="p">,</span>
    <span class="n">division</span><span class="p">,</span>
    <span class="n">print_function</span><span class="p">,</span>
    <span class="n">unicode_literals</span><span class="p">,</span>
<span class="p">)</span>

<span class="kn">import</span> <span class="nn">sys</span>
<span class="kn">from</span> <span class="nn">builtins</span> <span class="kn">import</span> <span class="nb">open</span>

<span class="k">try</span><span class="p">:</span>
    <span class="kn">from</span> <span class="nn">future</span> <span class="kn">import</span> <span class="n">standard_library</span>
    <span class="n">standard_library</span><span class="o">.</span><span class="n">install_aliases</span><span class="p">()</span>
<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
    <span class="k">pass</span>

<span class="kn">from</span> <span class="nn">.circuit</span> <span class="kn">import</span> <span class="n">Circuit</span>
<span class="kn">from</span> <span class="nn">.common</span> <span class="kn">import</span> <span class="n">builtins</span>
<span class="kn">from</span> <span class="nn">.config_</span> <span class="kn">import</span> <span class="n">SkidlConfig</span>
<span class="kn">from</span> <span class="nn">.part</span> <span class="kn">import</span> <span class="n">default_empty_footprint_handler</span>
<span class="kn">from</span> <span class="nn">.pin</span> <span class="kn">import</span> <span class="n">Pin</span>
<span class="kn">from</span> <span class="nn">.utilities</span> <span class="kn">import</span> <span class="n">export_to_all</span>


<span class="n">__all__</span> <span class="o">=</span> <span class="p">[</span>
    <span class="s2">&quot;config&quot;</span><span class="p">,</span>
    <span class="s2">&quot;lib_search_paths&quot;</span><span class="p">,</span>
    <span class="s2">&quot;footprint_search_paths&quot;</span><span class="p">,</span>
    <span class="s2">&quot;ERC&quot;</span><span class="p">,</span>
    <span class="s2">&quot;erc_assert&quot;</span><span class="p">,</span>
    <span class="s2">&quot;generate_netlist&quot;</span><span class="p">,</span>
    <span class="s2">&quot;generate_pcb&quot;</span><span class="p">,</span>
    <span class="s2">&quot;generate_xml&quot;</span><span class="p">,</span>
    <span class="s2">&quot;generate_schematic&quot;</span><span class="p">,</span>
    <span class="s2">&quot;generate_svg&quot;</span><span class="p">,</span>
    <span class="s2">&quot;generate_graph&quot;</span><span class="p">,</span>
    <span class="s2">&quot;reset&quot;</span><span class="p">,</span>
    <span class="s2">&quot;backup_parts&quot;</span><span class="p">,</span>
    <span class="s2">&quot;empty_footprint_handler&quot;</span><span class="p">,</span>
    <span class="s2">&quot;POWER&quot;</span><span class="p">,</span>
<span class="p">]</span>

<span class="k">try</span><span class="p">:</span>
    <span class="c1"># Set char encoding to UTF-8 in Python 2.</span>
    <span class="n">reload</span><span class="p">(</span><span class="n">sys</span><span class="p">)</span>  <span class="c1"># Causes exception in Python 3.</span>
    <span class="n">sys</span><span class="o">.</span><span class="n">setdefaultencoding</span><span class="p">(</span><span class="s2">&quot;utf8&quot;</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">NameError</span><span class="p">:</span>
    <span class="c1"># Do nothing with char encoding in Python 3.</span>
    <span class="k">pass</span>


<span class="c1">###############################################################################</span>
<span class="c1"># Globals that are used by everything else.</span>
<span class="c1">###############################################################################</span>

<span class="c1"># Get SKiDL configuration and set global search paths.</span>
<span class="n">config</span> <span class="o">=</span> <span class="n">SkidlConfig</span><span class="p">()</span>
<span class="n">lib_search_paths</span> <span class="o">=</span> <span class="n">config</span><span class="o">.</span><span class="n">lib_search_paths</span>
<span class="n">footprint_search_paths</span> <span class="o">=</span> <span class="n">config</span><span class="o">.</span><span class="n">footprint_search_paths</span>

<span class="c1"># Create the default Circuit object that will be used unless another is explicitly created.</span>
<span class="n">builtins</span><span class="o">.</span><span class="n">default_circuit</span> <span class="o">=</span> <span class="n">Circuit</span><span class="p">()</span>

<span class="c1"># NOCONNECT net for attaching pins that are intentionally left open.</span>
<span class="n">builtins</span><span class="o">.</span><span class="n">NC</span> <span class="o">=</span> <span class="n">default_circuit</span><span class="o">.</span><span class="n">NC</span>  <span class="c1"># pylint: disable=undefined-variable</span>

<span class="c1"># Create calls to functions on whichever Circuit object is the current default.</span>
<span class="n">ERC</span> <span class="o">=</span> <span class="n">default_circuit</span><span class="o">.</span><span class="n">ERC</span>
<span class="n">erc_assert</span> <span class="o">=</span> <span class="n">default_circuit</span><span class="o">.</span><span class="n">add_erc_assertion</span>
<span class="n">generate_netlist</span> <span class="o">=</span> <span class="n">default_circuit</span><span class="o">.</span><span class="n">generate_netlist</span>
<span class="n">generate_pcb</span> <span class="o">=</span> <span class="n">default_circuit</span><span class="o">.</span><span class="n">generate_pcb</span>
<span class="n">generate_xml</span> <span class="o">=</span> <span class="n">default_circuit</span><span class="o">.</span><span class="n">generate_xml</span>
<span class="n">generate_schematic</span> <span class="o">=</span> <span class="n">default_circuit</span><span class="o">.</span><span class="n">generate_schematic</span>
<span class="n">generate_svg</span> <span class="o">=</span> <span class="n">default_circuit</span><span class="o">.</span><span class="n">generate_svg</span>
<span class="n">generate_graph</span> <span class="o">=</span> <span class="n">default_circuit</span><span class="o">.</span><span class="n">generate_graph</span>
<span class="n">reset</span> <span class="o">=</span> <span class="n">default_circuit</span><span class="o">.</span><span class="n">reset</span>
<span class="n">backup_parts</span> <span class="o">=</span> <span class="n">default_circuit</span><span class="o">.</span><span class="n">backup_parts</span>
<span class="n">no_files</span> <span class="o">=</span> <span class="n">default_circuit</span><span class="o">.</span><span class="n">no_files</span>

<span class="n">empty_footprint_handler</span> <span class="o">=</span> <span class="n">default_empty_footprint_handler</span>

<span class="c1"># Define a tag for nets that convey power (e.g., VCC or GND).</span>
<span class="n">POWER</span> <span class="o">=</span> <span class="n">Pin</span><span class="o">.</span><span class="n">drives</span><span class="o">.</span><span class="n">POWER</span>


<div class="viewcode-block" id="get_default_tool">
<a class="viewcode-back" href="../../rst_output/skidl.skidl.html#skidl.skidl.get_default_tool">[docs]</a>
<span class="nd">@export_to_all</span>
<span class="k">def</span> <span class="nf">get_default_tool</span><span class="p">():</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Get the ECAD tool that will be used by default.&quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="n">config</span><span class="o">.</span><span class="n">tool</span></div>


<div class="viewcode-block" id="set_default_tool">
<a class="viewcode-back" href="../../rst_output/skidl.skidl.html#skidl.skidl.set_default_tool">[docs]</a>
<span class="nd">@export_to_all</span>
<span class="k">def</span> <span class="nf">set_default_tool</span><span class="p">(</span><span class="n">tool</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Set the ECAD tool that will be used by default.&quot;&quot;&quot;</span>
    <span class="n">config</span><span class="o">.</span><span class="n">tool</span> <span class="o">=</span> <span class="n">tool</span></div>

</pre></div>

            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
<search id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">SKiDL 1.2.2 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../index.html" >Module code</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">skidl.skidl</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
    &#169; Copyright 2016-2024, Dave Vandenbout.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 7.3.7.
    </div>
  </body>
</html>